<template>
  <div class="login-container flx-center">
    <div class="login-box">
      <div class="login-left"></div>
      <div class="login-form">
        <div class="login-logo">
          <img class="login-icon" src="/logo.svg" alt="" />
          <h2 class="logo-text">配置中心</h2>
        </div>
        <InitForm v-if="ifInit" />
        <UpdateForm v-if="!ifInit" :projectid="projectid" />
      </div>
    </div>
  </div>
</template>

<script setup lang="ts" name="Init">
import InitForm from './components/InitForm.vue'
import UpdateForm from './components/UpdateForm.vue'
import { ref, onMounted } from 'vue'
import { getallproject } from '@api/init'
let ifInit = ref<Boolean>(true)
let projectid = ref(0)

const getconfig = async () => {
  let data: any = await getallproject()

  if (Number(data.code) == 0) {
    if (Number(data.data.total) > 0) {
      ifInit.value = false
      projectid.value = data.data.records[0].id
    }
  }
}
onMounted(() => {
  getconfig()
})
</script>

<style scoped lang="scss">
@import './index.scss';
</style>
